module ApplicationHelper

  def page_level_messages
    messages = ''
    for message_type in [:error, :notice]
      if flash[message_type]
          messages << content_tag('div', content_tag('p',flash[message_type], :class => message_type), :class => 'page_message', :id => "page_message_#{message_type}")
      end
    end
    messages
  end

  def format_date(date)
    date.to_s(:long)
  end

  def percent_complete(distance,goal)
    if goal < 1
      0 
    elsif distance > goal
      100
    else
      (distance / goal * 100).round.to_i
    end
  end

end
